package no.sachmuld.methodcombination.examples.annotation.combo.courier;

import no.sachmuld.aspectjattach.AspectJAgent;

/**
 *
 */
public class Main implements Runnable {

    @Override
    public void run() {

        Main.class.getClassLoader().setDefaultAssertionStatus(true);
        AspectJAgent.initializeIfNeeded();

        new Runnable() {

            @Override
            public void run() {

                Courier[] couriers = {
                        new Courier().with(new ExpressDelivery(), new LoggingBehaviour()),
                        new Courier().with(new SlowDelivery())
                };

                for (Courier courier : couriers) {
                    try {
                        Delivery delivery = courier.deliver(new Package(1));
                        System.out.println(delivery);
                    } catch (AssertionError e) {
                        System.out.println("Violates contract: " + e.getMessage());
                    }
                }

            }

        }.run();

    }

    public static void main(String... args) {

        new Main().run();

    }

}
